﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ca2simulator.shared
{
    [Serializable]
    public class CA2
    {
        private Lattice _InitialLattice;
        private Lattice _Lattice;
        private ITransferFunc _Transfer;

        public Lattice Lattice { get { return _Lattice; } set { _Lattice = value; } }
        public ITransferFunc Transfer{get{return _Transfer;}}
        public Lattice InitialLattice { get { return _InitialLattice; } }

        public CA2(ITransferFunc transfer, Lattice initialLattice)
        {
            _Lattice = new Lattice(new CellState(), initialLattice.Rows, initialLattice.Columns);
            _Transfer = transfer;
            _InitialLattice = initialLattice;
            initialize();
        }

        public void initialize()
        {
            for (int i = 0; i < Lattice.Rows; i++)
            {
                for (int j = 0; j < Lattice.Columns; j++)
                {
                    // Cells are structs, so this will be assign by value not reference
                    Lattice[i, j] = InitialLattice[i, j];
                }
            }
        }
    }
}
